package com.lin.chapter36;

/**
 * 观察者模式＋中介者模式
 */
public class Client {
    public static void main(String[] args) {
        EventDispatch dispatch = EventDispatch.getEventDispatch();
        dispatch.registerCustomer(new Beggar());
        dispatch.registerCustomer(new Commoner());
        dispatch.registerCustomer(new NobleMan());

        ProductManager factory = new ProductManager();
        System.out.println("========模拟创建产品事件==========");
        System.out.println("创建一个叫做小男孩的原子弹");
        Product product = factory.createProduct("小男孩原子弹");

        System.out.println("\n=======模拟修改产品事件＝＝＝＝＝＝＝");
        System.out.println("把小男孩原子弹修改为胖子号原子弹");
        factory.editProduct(product, "胖子号原子弹");

        System.out.println("\n=======模拟克隆产品事件===========");
        System.out.println("克隆胖子号原子弹");
        factory.clone(product);

        System.out.println("\n=======模拟销毁产品事件===========");
        System.out.println("遗弃胖子号原子弹");
        factory.abandonProduct(product);
    }
}
